<!-- character_search.html -->
{% extends 'homepage.html' %}

{% block content %}

<style type="text/css">
    #characterTable {width:auto;}
    table td.center {
    text-align: center;
}
table td.params {
    text-align: left;
    font-family: monospace;
}

.modulus {
    font-family: serif;
    vertical-align: top;
    padding-top: 1em;
    border-right: 2px solid #8a8;
}
.modulus a { display: inline; font-family: serif; }
.modulus font { display: inline; font-family: serif }
.chi {
    padding: 30px 30px;
    font-family: serif;
    width: 7em;
    display: inline;
    white-space:nowrap;}
.chi a { display: inline; font-family: serif;}
.primitive {
  color:green;
}
.nonprimitive {
    color:blue;
}
.heading {
    padding: 30px 30px
}
</style>

<script>
 $(document).ready(function() {
     $('#characterTable').dataTable({
        "oLanguage": {
                "oPaginate": {
                        "sPrevious": "",
                        "sNext": ""
                }
        },
         "bFilter":false,
         "bAutoWidth": false, 
         "iDisplayLength":10, 
         "aoColumnDefs": [ 
           { "sType": 'title-numeric',
             "aTargets": [0] }, 
         ],
         "aLengthMenu": [[20, 50, -1], [20, 50, 100]],
         "fnRowCallback": function( row, data, index ){ 
             MathJax.Hub.Queue(['Typeset', MathJax.Hub, row]);
             return row;
         }

    });
});
</script>

<h2> Further refine search </h2>
<form>
    {#<input type="hidden" name="start" value="{{start}}"/>#}
    <table border="0">
        <tr>
            <td align=left> {{ KNOWL('character.dirichlet.modulus', title="modulus") }}  
                <input type = 'text' name = 'modulus' size=10 value={{modulus}}>
            </td>
            <td align=left> {{ KNOWL('character.dirichlet.conductor', title="conductor") }} 
                <input type='text' name='conductor' size=10 value={{conductor}}>
            </td>
            <td align=left> {{ KNOWL('character.dirichlet.order', title="order") }} 
                <input type='text' name='order'size=10 value={{order}}>
            </td>
        </tr>
{#<td align=left colspan=4>Maximum number of characters to display <input type='text' name='count' value={{count}} size=10>#}
    </table>
    <p></p>
    <td>
        <button type='submit' value='refine'>Search again</button>
    </td>
</form>

<h2>
    {% if order|int == 2 %} 
        Results for quadratic characters (given as {{ KNOWL('character.dirichlet.kronecker_symbol') }} )
    {% else %} 
        Results
    {% endif %} 
</h2>

<table class="ntdata" style="table-layout:fixed" id="characterTable">
    <thead class="heading" align="center">
    <tr>
        <th style="width: 5em"> {{ KNOWL('character.dirichlet', title="character") }}</th>
        <th style="width: 5em"> {{ KNOWL('character.dirichlet.modulus', title="modulus") }}</th>
        <th style="width: 6em"> {{ KNOWL('character.dirichlet.conductor', title="conductor") }}</th>
        <th style="width: 4em"> {{ KNOWL('character.dirichlet.order', title="order") }}</th>
        <th style="width: 4em"> {{ KNOWL('character.dirichlet.parity', title="parity") }}</th>
    </tr>
    </thead>
    
    <tbody>
        {% set row_class = cycler('odd', 'even') %}
	{# Keep track of the row number when iterating
	   A jinja bug prevents just using set on a variable
	   xrange is lazy, so as long as there is no penalty to having
	     a large list.  This will work as long as there are no more than
	     1000000 elements in the range #}
	{% set counter = range(1000000).__iter__() %}
        {% for line in contents %}
            {% for l in line %}
                {% for chi in l %}
                    <tr class="{{ row_class.next() }}">
                        <td class="modulus" align="center">
                            <a href="/Character/Dirichlet/{{chi[2]}}/{{chi[0]}}" title="{{counter.next()}}">
                                {% if chi[5] == "True"%}
                                    <font color="green">
                                {% else %}
                                    <font color="blue">
                                {% endif %} 
                                {% if chi[4] == 2 %}
                                    {{ chi[1] }}
                                {% else %}
                                \({\displaystyle \chi_{ {{ chi[2] }}}({{chi[0]}},&middot;)  }\)
                                {% endif %}
                                </font>
                            </a>
                        </td>
                        <td align=center>
                            <a href="/Character/Dirichlet/?modulus={{chi[2]}}&conductor={{conductor}}&order={{order}}&parity={{parity}}">
                                {{chi[2]}}
                            </a>
                        </td>
                        <td align=center>
                            <a href="/Character/Dirichlet/?modulus={{modulus}}&conductor={{chi[3]}}&order={{order}}&parity={{parity}}">{{chi[3]}}</a>
                        </td>
                        <td align=center>
                            <a href="/Character/Dirichlet/?modulus={{modulus}}&conductor={{conductor}}&order={{chi[4]}}&parity={{parity}}">{{chi[4]}}</a>
                        </td>
                        <td  align=center>
                            {% if chi[6] == "True" %}
                                Even
                            {% else %}
                                Odd
                            {% endif %}
                        </td>
                    </tr>
                {% endfor %}
            {% endfor %}
    {% endfor %}
    </tbody>
</table>
{% endblock %}
